package tedu.study.day03;

public class Day03Practise {
    public static void main(String[] args) {
        //1运算符
        //算数：+、-、*、/、%、++、--
        int a=5,b=7;
        System.out.println(a+b);//12
        System.out.println(a-b);//-2
        System.out.println(a*b);//35
        System.out.println(a/b);//0
        System.out.println(a%b);//5

        System.out.println(a++);//5--6
        System.out.println(++b);//8--8

        System.out.println(a--);//6--5
        System.out.println(--b);//7--7

        //关系：>、<、>=、<=、==、!=,比较后获取的结果为boolean
        a=5;
        b=7;
        boolean bflag = a>b;//false
        System.out.println(bflag);
        System.out.println(b>a);
        System.out.println(a<7);
        System.out.println(b>=a);
        System.out.println(a<=b);
        System.out.println(b==a+2);
        System.out.println(a!=b);

        //逻辑：&& 、 || 、 !
        a = 5;
        b = 7;
        int c = 10;
        boolean b3 = a>b && b<c;//false
        System.out.println(b3);
        System.out.println(a>b && b<c);//false
        System.out.println(a>=b || b<=c);//true
        System.out.println(!(a==b));//true
        //短路与、短路或
        b3 = a<b && c++>5;
        System.out.println(b3);//true
        System.out.println(c);//11
        b3 = a>b && c++>5;
        System.out.println(b3);//false
        System.out.println(c);//11

        c = 10;
        b3 = a<b || c++>5;
        System.out.println(b3);//true
        System.out.println(c);//10
        b3 = a>b || c++>5;
        System.out.println(b3);//true
        System.out.println(c);//11

        System.out.println(!b3);//false

        //赋值：
        //简单赋值 = 、
        //扩展赋值，自带强转 += 、 -=、 *= 、/= 、 %=
        short s =5;
        s = (short)(s+10);//15//short/byte/char,进行运算时默认转换为int，后续需要强转

        s += 5;//20; s = (short)(s+5);
        System.out.println(s);
        s -= 5;//15
        System.out.println(s);
        s *= 5;//75
        System.out.println(s);
        s /= 5;//15
        System.out.println(s);
        s %= 5;//0
        System.out.println(s);

        //字符串连接：+
        String name ="SD";
        int age = 39;
        System.out.println("name="+name);
        System.out.println("age="+age);
        System.out.println("我的名字是"+name);
        System.out.println("我已经"+age+"岁了");

        //两边为数字则做加法，两边有任意一边是字符串，则做字符串连接
        int t = 5;
        System.out.println(t+"1000");//51000
        System.out.println(10+20+""+30);//3030
        System.out.println(""+10+10+10);//101010
        System.out.println(20+20+20+"");//60

        String str = "+65+";
        System.out.println(str+"----");

        //条件/三目  一目 ++  -- ！
        int a6=5,b6=9;
        int num =b6>a6?b6:a6;
        System.out.println("a6和b6中最大的是："+num);

        int flag = a6>0?1:0;

        //顺序结构、分支结构、循环结构
        //分支结构if
        int score = 95;
        if(score%2==0){
            System.out.println(score+"是偶数");
        }
        double price = 600.0;
        if(price>=500){
            price *= 0.8;
        }

        //分支结构if else
        if(score >=0 && score<=100){
            System.out.println(score+"是合法成绩");
        }else{
            System.out.println(score+"不是合法成绩");
        }

        price = 300.0;
        if(price>=500){
            price *= 0.8;
        }else{
            price *= 0.9;
        }

        //scanner/scan
        //import
        //System
        //in
        //new
        //nextInt
        //nextDouble
        //switch
        //case
        //break
        //coomand
        //by
        //times
        //while
        //do
        //math
        //random
        //guess/guessing
        //game
        //level
        //count
        //score


    }
}
